package ruifeng.zcj.dig.ui.forum;

import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ruifeng.zcj.dig.R;
import ruifeng.zcj.dig.base.BaseBarFragment;
import ruifeng.zcj.dig.base.FragmentInfo;
import ruifeng.zcj.dig.base.ViewPagerFragmentAdapter;
import ruifeng.zcj.dig.base.api.OSChinaApi;
import ruifeng.zcj.dig.groble.FragmentArgs;
import ruifeng.zcj.dig.groble.ToActivityUtil;
import ruifeng.zcj.dig.ui.base.DepositFragment;
import ruifeng.zcj.dig.ui.base.RefreshRecyclerFragment;
import ruifeng.zcj.dig.ui.forum.bean.NewPost;
import ruifeng.zcj.dig.ui.forum.category.ChooseCategoryActivity;
import ruifeng.zcj.dig.ui.forum.parts.PartsActivity;
import ruifeng.zcj.dig.ui.forum.release.ReleaseForumActivity;
import ruifeng.zcj.dig.ui.home.recruit.RecruitFragment;
import ruifeng.zcj.dig.ui.shopping.ShoppingListActivity;
import ruifeng.zcj.dig.ui.shopping.bean.ThreeCategory;
import ruifeng.zcj.mybase.base.App;
import ruifeng.zcj.mybase.base.utils.UIUtils;
import ruifeng.zcj.mybase.base.utils2.AbJsonUtil;

/**
 * 论坛
 * Created by Administrator on 2016/8/31 0031.
 */
public class ForumFragment extends DepositFragment {

    @Bind(R.id.activity_top_center)
    TextView mActivityTopCenter;
    @Bind(R.id.activity_top_right_text)
    TextView mActivityTopRightText;
    @Bind(R.id.activity_top_right)
    ImageView mActivityTopRight;
    @Bind(R.id.activity_top_left)
    ImageView mActivityTopLeft;

    @Bind(R.id.iv_pic)
    ImageView mIvPic;

    @Bind(R.id.home_fragment_img1)
    ImageView mHomeFragmentImg1;
    @Bind(R.id.home_fragment_text1)
    TextView mHomeFragmentText1;
    @Bind(R.id.home_fragment_relative1)
    RelativeLayout mHomeFragmentRelative1;
    @Bind(R.id.home_fragment_img2)
    ImageView mHomeFragmentImg2;
    @Bind(R.id.home_fragment_text2)
    TextView mHomeFragmentText2;
    @Bind(R.id.home_fragment_relative2)
    RelativeLayout mHomeFragmentRelative2;
    @Bind(R.id.home_fragment_img3)
    ImageView mHomeFragmentImg3;
    @Bind(R.id.home_fragment_text3)
    TextView mHomeFragmentText3;
    @Bind(R.id.home_fragment_relative3)
    RelativeLayout mHomeFragmentRelative3;
    @Bind(R.id.home_fragment_img4)
    ImageView mHomeFragmentImg4;
    @Bind(R.id.home_fragment_text4)
    TextView mHomeFragmentText4;
    @Bind(R.id.home_fragment_relative4)
    RelativeLayout mHomeFragmentRelative4;
    @Bind(R.id.other_fragment_img1)
    ImageView mOtherFragmentImg1;
    @Bind(R.id.other_fragment_text1)
    TextView mOtherFragmentText1;
    @Bind(R.id.home_fragment_relative5)
    RelativeLayout mHomeFragmentRelative5;
    @Bind(R.id.other_fragment_img2)
    ImageView mOtherFragmentImg2;
    @Bind(R.id.other_fragment_text2)
    TextView mOtherFragmentText2;
    @Bind(R.id.home_fragment_relative6)
    RelativeLayout mHomeFragmentRelative6;
    @Bind(R.id.other_fragment_img3)
    ImageView mOtherFragmentImg3;
    @Bind(R.id.other_fragment_text3)
    TextView mOtherFragmentText3;
    @Bind(R.id.home_fragment_relative7)
    RelativeLayout mHomeFragmentRelative7;
    @Bind(R.id.other_fragment_img4)
    ImageView mOtherFragmentImg4;
    @Bind(R.id.other_fragment_text4)
    TextView mOtherFragmentText4;
    @Bind(R.id.home_fragment_relative8)
    RelativeLayout mHomeFragmentRelative8;
    @Bind(R.id.color_name)
    TextView mColorName;
    @Bind(R.id.color)
    View mColor;

    @Bind(R.id.view_pager)
    ViewPager mViewPager;

    /***
     * 设置缓存页数
     * ***/
    public void setScreenPageLimit() {
        mViewPager.setOffscreenPageLimit(mBaseFragmentViewPageAdapter.getCount());
    }

    @Override
    protected void addPage(ArrayList<String> tabTitles, ArrayList<FragmentInfo> fragmentInfos) {
        tabTitles.add("测试下哈");
        fragmentInfos.add(new FragmentInfo(NewPostFragment.class, getBundle(1)));
    }




    @Override
    protected void initFragmentConfig(View view) {
        mActivityTopCenter.setText("论坛");
        mColorName.setText("最新帖子");
        mIvPic.setImageResource(R.drawable.banner_forum);
        mColor.setBackgroundResource(R.drawable.yellow_h);

        mActivityTopLeft.setVisibility(View.INVISIBLE);
//        mActivityTopRight.setImageResource(R.drawable.personal_h);


        mHomeFragmentImg1.setImageResource(R.drawable.post_h);
        mHomeFragmentText1.setText("发帖");
        mHomeFragmentImg2.setImageResource(R.drawable.talk_h);
        mHomeFragmentText2.setText("今日杂谈");
        mHomeFragmentImg3.setImageResource(R.drawable.hot_h);
        mHomeFragmentText3.setText("热帖");
        mHomeFragmentImg4.setImageResource(R.drawable.search_h);
        mHomeFragmentText4.setText("搜索");

        mOtherFragmentImg1.setImageResource(R.drawable.recruit_home);
        mOtherFragmentText1.setText("招聘求职");
        mOtherFragmentImg2.setImageResource(R.drawable.parts_h);
        mOtherFragmentText2.setText("二手配件");
        mOtherFragmentImg3.setImageResource(R.drawable.consultation_h);
        mOtherFragmentText3.setText("故障咨询");
        mOtherFragmentImg4.setImageResource(R.drawable.share_h);
        mOtherFragmentText4.setText("资料分享");

        super.initFragmentConfig(view);
    }

    @Override
    public int getContentView() {
        return R.layout.fragment_forum2;
    }

    @Override
    protected void onFirstUserVisible() {

    }

    @Override
    protected void onUserVisible() {

    }

    @Override
    protected void onUserInvisible() {

    }

    @Override
    protected void cleanMemory() {

    }


    @OnClick({R.id.activity_top_right, R.id.iv_pic, R.id.home_fragment_relative1, R.id.home_fragment_relative2, R.id.home_fragment_relative3, R.id.home_fragment_relative4, R.id.home_fragment_relative5, R.id.home_fragment_relative6, R.id.home_fragment_relative7, R.id.home_fragment_relative8})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.activity_top_right:
                showSnackBar("点击了我");
                break;
            case R.id.iv_pic:
                break;
            case R.id.home_fragment_relative1:
           //     ThreeCategory.RowsBean rowsBean = category.getRows().get(position);
              //  FragmentArgs fragmentArgs2 = new FragmentArgs();
             //   fragmentArgs2.add("ThreeCategory", rowsBean);
                ToActivityUtil.toNextActivity(getContext(), ReleaseForumActivity.class, "threecategoryBundle", null);

                break;
            case R.id.home_fragment_relative2:
                FragmentArgs fragmentArgs2 = new FragmentArgs();
                fragmentArgs2.add("category", 1);
                ToActivityUtil.toNextActivity(getContext(), ChooseCategoryActivity.class, "categoryBudle", fragmentArgs2);
                break;
            case R.id.home_fragment_relative3:
                break;
            case R.id.home_fragment_relative4:
                break;
            case R.id.home_fragment_relative5:
                break;
            case R.id.home_fragment_relative6:
             /*   FragmentArgs fragmentArgs3 = new FragmentArgs(); , "categoryBudle", fragmentArgs3
                fragmentArgs3.add("category", 1);*/
                ToActivityUtil.toNextActivity(getContext(), PartsActivity.class);

                break;
            case R.id.home_fragment_relative7:
                FragmentArgs fragmentArgs4 = new FragmentArgs();
                fragmentArgs4.add("category", 1);
                ToActivityUtil.toNextActivity(getContext(), ChooseCategoryActivity.class, "categoryBudle", fragmentArgs4);

                break;
            case R.id.home_fragment_relative8:
                FragmentArgs fragmentArgs5 = new FragmentArgs();
                fragmentArgs5.add("category", 1);
                ToActivityUtil.toNextActivity(getContext(), ChooseCategoryActivity.class, "categoryBudle", fragmentArgs5);

                break;
        }
    }


}
